local gongqing = fk.CreateSkill {

  name = "joy__gongqing",

  tags = { Skill.Compulsory, },

}



gongqing:addEffect(fk.DamageInflicted, {
  name = "joy__gongqing",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(gongqing.name) and data.from then
      return data.from:getAttackRange() >= 3 or data.damage > 1
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.from:getAttackRange() < 3 then
      data.damage = 1
      player:broadcastSkillInvoke(gongqing.name, 1)
      room:notifySkillInvoked(player, gongqing.name, "defensive")
    elseif data.from:getAttackRange() > 3 then
      player:drawCards(1, gongqing.name)
      player:broadcastSkillInvoke(gongqing.name, 2)
      room:notifySkillInvoked(player, gongqing.name, "drawcard")
    end
  end,
})

return gongqing